package com.hansming.bss.modules.sfc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hansming.bss.common.persistence.Page;
import com.hansming.bss.common.service.CrudService;
import com.hansming.bss.modules.sfc.dao.CarInfoDao;
import com.hansming.bss.modules.sfc.entity.CarInfo;
import com.hansming.bss.modules.sfc.util.PageBean;

/**
 * 房车信息Service
 * @author Hansming
 * @version 2017-09-18
 */
@Service
@Transactional(readOnly = true)
public class CarInfoService extends CrudService<CarInfoDao,CarInfo> {
	
	@Autowired
	private CarInfoDao carInfoDao;
	
	public Page<CarInfo> findPage(Page<CarInfo> page,CarInfo carInfo){		
		carInfo.getSqlMap().put("dsf", dataScopeFilter(carInfo.getCurrentUser(),"o","u"));
		return super.findPage(page, carInfo);
	}
	
	//得到首页城市菜单栏的房车信息
	public List<CarInfo> findFirstPageCarInfoInMenuByCity(String city){
		return carInfoDao.findFirstPageCarInfoInMenuByCity(city);
	}
	
	//得到首页导航栏的注册信息
	public List<CarInfo> findFirstPageCarInfoInNav(){
		return carInfoDao.findFirstPageCarInfoInNav();
	}
	
	//根据搜索条件得到房车列表页的房车列表
	@Transactional(readOnly = false)
	public List<CarInfo> getPageList(CarInfo carInfo,PageBean page,int sortid,int orderid){
		return carInfoDao.getPageList(carInfo, page, sortid, orderid);
	}
	
	
	//============后台操作的Service=================
	
		//得到房车的连接表的信息
		public CarInfo getCarAndCarextr(CarInfo carinfo){
			return carInfoDao.getCarAndCarextr(carinfo);
		}
	
		//设置该房车为显示在首页城市菜单栏的房车
		public int updateCarInMenu(CarInfo car){
			return carInfoDao.updateCarInMenu(car);
		}
		
		//取消显示在首页城市菜单栏的房车
		public int deleteCarInMenu(CarInfo car){
			return carInfoDao.deleteCarInMenu(car);
		}
		
		//设置该房车为显示在首页城市菜单栏的房车
		public int updateCarInNav(CarInfo car){
			return carInfoDao.updateCarInNav(car);
		}
			
		//取消显示在首页城市菜单栏的房车
		public int deleteCarInNav(CarInfo car){
			return carInfoDao.deleteCarInNav(car);
		}
		
		//更新房车菜单的排序sort属性
		@Transactional(readOnly = false)
		public void updatesort(CarInfo carinfo){
			carInfoDao.updatesort(carinfo);
		}
		
		//添加房车价格页面选择租车信息列表的方法
		public List<CarInfo> findCarByPageAndCar(CarInfo carinfo,PageBean page){
			return carInfoDao.findCarByPageAndCar(carinfo, page);
		}
		
		
		//查找汽车标签（服务）
		  public CarInfo querytag(String id){
		   return carInfoDao.querytag(id);
		  }
		  
		  //保存汽车详情
		  @Transactional(readOnly = false)
		  public void savedetails(String details,String id){
		   carInfoDao.savedetails(details,id);
		  }
		  //查找汽车
		  public String querydetails(String id){
		   return carInfoDao.querydetails(id);
		  }
		
		
		
		//=====================小程序操作Service=====================
		
		//搜索房车列表
		public List<CarInfo> findCarListInMiniapp(String city,String drive,String transmission,int bed,String oiltype,int passengers,int sortid,int orderid){
			return carInfoDao.findCarListInMiniapp(city, drive, transmission, bed, oiltype, passengers, sortid, orderid);
		}
		
	//=========================Pc操作Service=========================
		public List<CarInfo> getCarsInIndex(){
			return carInfoDao.getCarsInIndex();
		}
		
		
		//首页下方导航栏根据城市来搜索排名靠前的4辆房车信息
		public List<CarInfo> getCarsInNav(String city){
			return carInfoDao.getCarsInNav(city);
		}
		
		//搜索房车列表
		public List<CarInfo> findCarListInMiniapppage(String city,String drive,String transmission,int bed,String oiltype,int passengers,int sortid,int orderid,PageBean page){
			return carInfoDao.findCarListInMiniapppage(city, drive, transmission, bed, oiltype, passengers, sortid, orderid,page);
		}
}
